package kr.hkit.powerjava.work;

import java.util.Arrays;

public class Stack {
	private int size;
	private int top;
	private String[] arrItem;
	
	public Stack(int size) {
		this.size = size;
		arrItem = new String[size];
		top = -1;
	}
	
	public void push(String item) {
		if (!isFull()) {
			arrItem[++top] = item;
		}else{
			System.out.println("Stack is Full");
		}
	}
	
	public String pop() {
		if (!isEmpty()) {
			return arrItem[top--];
		}else{
			return "Stack is Empty";
		}
	}
	
	public boolean isFull(){
		return top==size-1;
	}
	
	public boolean isEmpty(){
		return top==-1;
	}
	
	public void prnStack(){
		for(int i = 0; i <= top; i++) {
			System.out.printf("[%s]\t", arrItem[i]);
		}
		System.out.println();
	}

	@Override
	public String toString() {
		return String.format("%s\n", Arrays.toString(arrItem));
	}
	
}